package com.hitfm.iplay.db;

import android.content.ContentValues;
import android.content.Context;

public class RatingDAO extends DatabaseHelper {
	public RatingDAO(Context mContext) {
		super(mContext, DB_NAME, DB_VERSION, DB_CREATE, DB_TABLE, RATINGCOLUMNS);
	}

	// 表中一条数据的名称
	public static final String KEY_ID = "_id";
	// 表中一条数据的内容
	public static final String KEY_URL = "url";
	// 表中一条数据的内容
	private static final String KEY_RATE = "rate";
	// 表中一条数据的内容
	public static final String KEY_SINGER = "singer";
	// 表中一条数据的内容
	public static final String KEY_SONGNAME = "songname";
	// 表中一条数据的内容
	public static final String KEY_ALBUM = "album";

	private static String[] RATINGCOLUMNS = new String[] { KEY_ID, KEY_URL,
			KEY_RATE, KEY_SINGER, KEY_SONGNAME, KEY_ALBUM };
	// 数据库名称为iplay.db
	private static final String DB_NAME = "iplay.db";
	// 数据库表名
	private static final String DB_TABLE = "rating";
	// 数据库版本
	private static final int DB_VERSION = 1;
	// 创建一个表
	private static final String DB_CREATE = "CREATE TABLE IF NOT EXISTS "
			+ DB_TABLE + "(" 
			+ KEY_ID + " INTEGER PRIMARY KEY," 
			+ KEY_URL+ " STRING," 
			+ KEY_RATE + " STRING," 
			+ KEY_SINGER +" STRING,"
			+ KEY_SONGNAME +" STRING,"
			+ KEY_ALBUM +" STRING"
			+ ")";

	/* 插入一条数据 */
	public long insertData(String url, String rate,String singer,String songname,String album) {

		ContentValues initialValues = new ContentValues();
		initialValues.put(KEY_URL, url);
		initialValues.put(KEY_RATE, rate);
		initialValues.put(KEY_SINGER, singer);
		initialValues.put(KEY_SONGNAME, songname);
		initialValues.put(KEY_ALBUM, album);
		return super.insertData(initialValues);
	}

}